package com.guanyong.webapi.controllers.api;

import com.guanyong.model.UserBaseModel;
import com.guanyong.model.VideoReportModel;
import com.guanyong.services.VideoReprotService;
import com.guanyong.utils.Comm.ResultCode;
import com.guanyong.utils.Comm.ResultObject;
import com.guanyong.webapi.handle.UserHandle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by mxk on 2017/7/6.
 */

@RestController
@RequestMapping("/api/videreport/")
public class VideoReprotApi {

    @Autowired
    VideoReprotService videoReprotService;

    @Autowired
    UserHandle userHandle;

    @RequestMapping(value = "addreport", method = RequestMethod.POST)
    ResultObject<Integer> addBarrage(HttpServletRequest request,
                                     @RequestParam Integer classtype,
                                     @RequestParam String objectid) {
        ResultObject<Integer> resultObject=new ResultObject<Integer>();
        UserBaseModel userBaseModel = userHandle.getCurUser(request);
        if (userBaseModel != null && !userBaseModel.getfId().equals("")) {
            VideoReportModel videoReportModel=new VideoReportModel();
            videoReportModel.setfClasstype(classtype);
            videoReportModel.setfObjectid(objectid);
            videoReportModel.setfUserid(userBaseModel.getfId());

            resultObject=videoReprotService.AddVideoReprot(videoReportModel);
        }
        else{
            resultObject.setCode(ResultCode.NoLogin);
        }
        return resultObject;
    }

}
